#include <unordered_map>
#include <vector>
using namespace std;
int subarraySum(vector<int>& nums, int k) {
	unordered_map<int, int> cnt;
	cnt[0] = 1;
	int sum = 0;
	int ret = 0;
	int n = nums.size();
	for (int i = 0; i < n; ++i) {
		sum += nums[i];
		ret += cnt[sum - k];
		++cnt[sum];
	}
	return ret;
}